package cn.getech.data.development.controller.api;

import cn.getech.data.development.api.WorkMenuJobRelApi;
import cn.getech.data.development.entity.WorkMenuJobRel;
import cn.getech.data.development.service.IWorkMenuJobRelService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName JobInfoApiController
 * @Description TODO
 * @Author Getech
 * @Date 2020/12/24 11:46
 */
@RestController
public class WorkMenuJobRelApiController implements WorkMenuJobRelApi {

    @Autowired
    private IWorkMenuJobRelService iWorkMenuJobRelService;

    @Override
    public List<WorkMenuJobRel> list(WorkMenuJobRel workMenuJobRelSearchData) {
        QueryWrapper<WorkMenuJobRel> workMenuJobRelQueryWrapper = new QueryWrapper<>();
        if(null != workMenuJobRelSearchData){
            workMenuJobRelQueryWrapper.eq(null != workMenuJobRelSearchData.getWorkMenuId(),"work_menu_id",workMenuJobRelSearchData.getWorkMenuId());
            workMenuJobRelQueryWrapper.eq(null != workMenuJobRelSearchData.getWorkType(),"work_type",workMenuJobRelSearchData.getWorkType());
            workMenuJobRelQueryWrapper.eq(null != workMenuJobRelSearchData.getWorkFlowId(),"work_flow_id",workMenuJobRelSearchData.getWorkFlowId());
        }
        return iWorkMenuJobRelService.list(workMenuJobRelQueryWrapper);
    }

    @Override
    public WorkMenuJobRel getOne(WorkMenuJobRel workMenuJobRelSerachData) {
        if(null != workMenuJobRelSerachData){
            QueryWrapper<WorkMenuJobRel> workMenuJobRelQueryWrapper = new QueryWrapper<>();
            workMenuJobRelQueryWrapper.eq(null != workMenuJobRelSerachData.getWorkType(),"work_type",workMenuJobRelSerachData.getWorkType());
            workMenuJobRelQueryWrapper.eq(null != workMenuJobRelSerachData.getWorkFlowId(),"work_flow_id",workMenuJobRelSerachData.getWorkFlowId());
            return iWorkMenuJobRelService.getOne(workMenuJobRelQueryWrapper);
        }
        return null;
    }
}
